<?php
namespace Admin\Controller;
use Think\Controller;
class UserController extends CommonController {
    public function userlist(){

        var_dump($_SESSION);

        $aid = $_SESSION['aid'];
        $path = MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME;

        var_dump($path);


        $auth=new \Think\Auth();  
        $res = $auth->check($path,$aid);

        var_dump($res);





    	$User = M('User'); // 实例化User对象
		$count = $User->count();// 查询满足要求的总记录数
		$Page = new \Think\Page($count,2);// 实例化分页类 传入总记录数和每页显示的记录数(25)
		$show  = $Page->show();// 分页显示输出
		// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$userlist = $User->order('ctime desc')->limit($Page->firstRow.','.$Page->listRows)->select();

		$this->assign('show',$show);
		$this->assign('userlist',$userlist);
        $this->display();
    }

    public function stop()
    {
    	$uid = I('post.uid');

    	$user  = M('user')->find($uid);

    	if($user['status']==1){
    		M('user')->where(['uid'=>$uid])->save(['status'=>'0']);

    		$this->ajaxReturn(['error'=>0,'info'=>'已启动']);
    	}else{

    		M('user')->where(['uid'=>$uid])->save(['status'=>'1']);

    		$this->ajaxReturn(['error'=>1,'info'=>'已停用']);
    	}
    }
}